package com.sinosoft.antiques.common;

import java.io.IOException;
import java.util.Properties;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * ClassName: ConfigReader Function: 配置文件Reader Reason:
 * 统一读取config.properties中的配置项
 *
 * @date: 2016-01-06 19:28:19
 * @author Qiaozhen
 * @version 1.0
 * @since JDK 1.7
 */
public class ConfigReader {
	static Properties prop = null;
	private static final Logger log = LogManager.getLogger(ConfigReader.class);
	static {
		prop = new Properties();

		try {
			prop.load(ConfigReader.class.getClassLoader().getResourceAsStream(
					"com/sinosoft/antiques/resources/config.properties"));
		} catch (IOException e) {
			log.error("Load config.properties error", e);
		}
	}

	/**
	 * getValue:(获取配置文件中key的value).
	 * 
	 * @author Qiaozhen
	 * @param key
	 * @return String value
	 * @since JDK 1.6
	 */
	public static String getValue(String key) {
		if (prop == null)
			return null;
		else
			return prop.getProperty(key);
	}

	/**
	 * getRight:(获取权限ID 如果没有则直接返回key值).
	 * 
	 * @author Qiaozhen
	 * @param key
	 * @return
	 * @since JDK 1.6
	 */
	public static String getRight(String key) {
		String right = getValue(key);
		return right == null ? key : right;
	}
}
